package com.hig.ledger.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hig.ledger.mapper.LedgerCertificatesMapper;
import com.hig.ledger.domain.LedgerCertificates;
import com.hig.ledger.service.ILedgerCertificatesService;

/**
 * 人员其他资质证件清单Service业务层处理
 * 
 * @author scp
 * @date 2024-09-22
 */
@Service
public class LedgerCertificatesServiceImpl implements ILedgerCertificatesService 
{
    @Autowired
    private LedgerCertificatesMapper ledgerCertificatesMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询人员其他资质证件清单
     * 
     * @param id 人员其他资质证件清单ID
     * @return 人员其他资质证件清单
     */
    @Override
    public LedgerCertificates selectLedgerCertificatesById(Long id)
    {
        return ledgerCertificatesMapper.selectLedgerCertificatesById(id);
    }

    /**
     * 查询人员其他资质证件清单列表
     * 
     * @param ledgerCertificates 人员其他资质证件清单
     * @return 人员其他资质证件清单
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<LedgerCertificates> selectLedgerCertificatesList(LedgerCertificates ledgerCertificates)
    {
        return ledgerCertificatesMapper.selectLedgerCertificatesList(ledgerCertificates);
    }

    /**
     * 新增人员其他资质证件清单
     * 
     * @param ledgerCertificates 人员其他资质证件清单
     * @return 结果
     */
    @Override
    public int insertLedgerCertificates(LedgerCertificates ledgerCertificates)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        ledgerCertificates.setCreateBy(loginUser.getUser().getUserName());
        ledgerCertificates.setDeptId(loginUser.getUser().getDeptId());
//        long id = ledgerCertificatesMapper.getNextId();
//        ledgerCertificates.setId(id);
        ledgerCertificates.setCreateTime(DateUtils.getNowDate());
        return ledgerCertificatesMapper.insertLedgerCertificates(ledgerCertificates);
    }

    /**
     * 修改人员其他资质证件清单
     * 
     * @param ledgerCertificates 人员其他资质证件清单
     * @return 结果
     */
    @Override
    public int updateLedgerCertificates(LedgerCertificates ledgerCertificates)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        ledgerCertificates.setUpdateBy(loginUser.getUser().getUserName());
        ledgerCertificates.setUpdateTime(DateUtils.getNowDate());
        return ledgerCertificatesMapper.updateLedgerCertificates(ledgerCertificates);
    }

    /**
     * 批量删除人员其他资质证件清单
     * 
     * @param ids 需要删除的人员其他资质证件清单ID
     * @return 结果
     */
    @Override
    public int deleteLedgerCertificatesByIds(Long[] ids)
    {
        return ledgerCertificatesMapper.deleteLedgerCertificatesByIds(ids);
    }

    /**
     * 删除人员其他资质证件清单信息
     * 
     * @param id 人员其他资质证件清单ID
     * @return 结果
     */
    @Override
    public int deleteLedgerCertificatesById(Long id)
    {
        return ledgerCertificatesMapper.deleteLedgerCertificatesById(id);
    }
}
